<?php

class atom_Intersect {
    function __construct($query, $fields) {
        $this->query_ = $query;
        $this->fields_ = $fields;
    }
}

class atom_AtomType {
    function __construct($typename) {
	$this->typename_ = $typename;
        $this->tables_ = array();
        $this->intersect_ = array();
    }

    function add_table($tablename) {
        array_push($this->tables_, $tablename);
    }

    function add_intersect($intersect) {
        array_push($this->intersect_, $intersect);
    }
};

class atom_Atom {
    function __construct($guid_str) {
	$this->guid = $guid_str;
        $result = mysql_query("SELECT * FROM neon_atom_meta WHERE guid = '$guid_str'");
        assert($result);

        if (! ($row = mysql_fetch_array($result, MYSQL_ASSOC))) {
            // XXX/bowei -- this probably needs to be better
            throw new Exception('invalid guid');
        }

        $this->type    = $row['type'];        
        $this->version = version_str2Vector($row['vv']);
        $this->deleted = intval($row['deleted']);
        $this->local   = intval($row['local']);
    }

    function guid() {
	return $this->guid;
    }

    function version() {
	return $this->version;
    }
};

?>
